<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>帐号注册</title>
    <base href="<?php echo base_url();?>">

    <!-- Bootstrap core CSS -->
    <link href="./style/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <![endif]-->
    <!--[if lt IE 9]>
    <script src="./style/js/respond.min.js"></script>
    <script src="./style/js/html5shiv.min.js"></script>
    <![endif]-->
</head>
<style type="text/css">
    body{
        padding-top: 50px;
        background-color: #d7d7d7;
    }
    .form-box{
        padding: 20px 20px;
    }
</style>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">下拉菜单</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="">主页</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="./help.html">帮助</a></li>
            </ul>
        </div>
    </div>
</nav>
<div class="container" style="padding-top:100px;padding-left: 0px;padding-right: 0px">
    <div class="col-lg-6" style="margin-top: 120px;">
        <img src="./style/img/8583.png" class="img-responsive">
    </div>
    <div class="col-lg-4 col-lg-offset-1 form-box" style="">
        <h1 class="text-center">帐号注册</h1>
        <form style="text-align: center" action="./account/register_result.html" method="post">
            <div class="form-group form-email">
                <label for="reg_email">注册邮箱</label>
                <input type="email" class="form-control" id="reg_email" name="email" required autofocus value="<?php echo set_value('email');?>">
            </div>
            <div class="form-group form-password">
                <label for="reg_password">密码</label>
                <input type="password" class="form-control" id="reg_password" name="password" placeholder="" maxlength="16" minlength="6">
            </div>
            <div class="form-group form-password">
                <label for="reg_password2">确认密码</label>
                <input type="password" class="form-control" id="reg_password2" name="password2" placeholder="" maxlength="16" minlength="6">
            </div>
            <p class="error-msg text-danger"><?php echo $errmsg;?><p>
            <?php echo form_error('email', '<p class="text-danger">', '</p>'); ?>
            <?php echo form_error('password', '<p class="text-danger">', '</p>'); ?>
            <?php echo form_error('password2', '<p class="text-danger">', '</p>'); ?>
            <button type="submit" class="btn btn-success btn-register" >提交</button>
        </form>
    </div>


</div>
</body>
<!-- Bootstrap core JavaScript
   ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./style/js/jquery-1.12.3.js"></script>
<script src="./style/js/bootstrap.min.js"></script>
<script src="./style/js/modal.js"></script>
<script src="./style/js/md5.js"></script>
<!-- Just to make our placeholder images work. Don't actually copy the next line! -->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script type="text/javascript">
    FormValidation = {
        rule:/[^0-9a-zA-Z_]/i,
        run:function (password) {
           if (typeof password == 'string'){
                if (password.search(this.rule) < 0){
                    return true;
                }else{
                    return false;
                }
           }
        }
    }

    $('.btn-register').click(function () {
        var pass1 = $('form #reg_password');
        var pass2 = $('form #reg_password2');
        var email = $('.form-email');

        var password1 = pass1.val();
        var password2 = pass2.val();


        if (!FormValidation.run(password1) || !FormValidation.run(password2) ){
            $('.error-msg').html('<strong class="text-danger">密码只能是数字字母下划线</strong>');
            return false;
        }
        if (password1 != password2){
            $('.error-msg').html('<strong class="text-danger">两次密码输入不一致</strong>');
            return false;
        }
        var password = $.md5(password1);
        pass1.val(password);
        pass2.val(password);
        return true;
    });

</script>
</html>